package clueless.client;

import java.awt.Color;
import java.awt.GridLayout;

import javax.swing.JPanel;
import javax.swing.border.LineBorder;

import clueless.utilities.Character;

public class GuiPanel extends JPanel {
	
	private JPanel characterPanel = new JPanel();
	private JPanel[] characterArea = new JPanel[6];
	
	JPanel getCharacterPanel() {
		return characterPanel;
	}
	void makeCharacterPanel(int vert)
	{
		if (vert == 1) {
			characterPanel.setLayout(new GridLayout(6,1));	
		} else {
			characterPanel.setLayout(new GridLayout(1,6));
		}
		
		for (int i=0; i<6; ++i) {
			characterArea[i] = new JPanel();
			characterPanel.add(characterArea[i]);
		}
	}
	
	public void setPlayer(String player) {
		switch (player) {
			case Character.m_COL_MUSTARD :
				setColMustard();
				break;
			case Character.m_MISS_SCARLET :
				setMsScarlet();
				break;
			case Character.m_MR_GREEN :
				setMrGreen();
				break;
			case Character.m_MRS_PEACOCK :
				setMrsPeacock();
				break;
			case Character.m_MRS_WHITE :
				setMrsWhite();
				break;
			case Character.m_PROF_PLUM :
				setProfPlum();
				break;
		}
	}
	
	public void setColMustard() {
		characterArea[0].setBackground(Color.YELLOW);
		characterArea[0].setBorder(new LineBorder(Color.black));
	}
	public void setMsScarlet() {
		characterArea[1].setBackground(Color.RED);
		characterArea[1].setBorder(new LineBorder(Color.black));
	}
	public void setMrGreen() {
		characterArea[2].setBackground(Color.GREEN);
		characterArea[2].setBorder(new LineBorder(Color.black));
	}
	public void setMrsPeacock() {
		characterArea[3].setBackground(Color.BLUE);
		characterArea[3].setBorder(new LineBorder(Color.black));
	}
	public void setMrsWhite() {
		characterArea[4].setBackground(Color.WHITE);
		characterArea[4].setBorder(new LineBorder(Color.black));
	}
	public void setProfPlum() {
		characterArea[5].setBackground(new Color(255, 0, 255));
		characterArea[5].setBorder(new LineBorder(Color.black));
	}
	
	public void clearPlayers() {
		for (int i=0; i<6; ++i) {
			characterArea[i].setBackground(this.getBackground());
			characterArea[i].setBorder(new LineBorder(this.getBackground()));
		}
	}
	
}
